<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script src="spellcheck_test.js"></script>

<script>
const inputText = [
  '<div contenteditable>',
    '<div>|OK</div>',
    '<div>OK zz OK</div>',
  '</div>'
].join('');

spellcheck_test(
    inputText,
    document => {
      const selection = document.getSelection();
      selection.modify('move', 'forward', 'line'); // |OK zz OK
      for (let i = 0; i < 3; ++i)
          selection.modify('move', 'forward', 'word'); // OK zz OK|
    },
    [
      '<div contenteditable>',
        '<div>OK</div>',
        '<div>OK #zz# OK</div>',
      '</div>'
    ].join(''),
    'Marker misspelling in two lines.');

spellcheck_test(
    inputText,
    document => {
      const selection = document.getSelection();
      selection.modify('move', 'forward', 'line'); // |OK zz OK
      document.execCommand('delete', false); // OK|OK zz OK
      selection.modify('move', 'right', 'line'); // OKOK zz OK|
    },
    [
      '<div contenteditable>',
        '<div>OKOK #zz# OK</div>',
      '</div>'
    ].join(''),
    'Marker misspelling after merging lines with delete.');

spellcheck_test(
    inputText,
    document => {
      const selection = document.getSelection();
      selection.modify('move', 'forward', 'character'); // O|K
      selection.modify('move', 'forward', 'character'); // OK|
      document.execCommand('forwardDelete', false); // OK|OK zz OK
      selection.modify('move', 'right', 'line'); // OKOK zz OK|
    },
    [
      '<div contenteditable>',
        '<div>OKOK #zz# OK</div>',
      '</div>'
    ].join(''),
    'Marker misspelling after merging lines with forward delete.');
</script>
